package com.asder.tool.generator.main;

import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableList;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collector;
import java.util.stream.Collectors;

/**
 * Created by zy on 2020/3/1.
 */
public class demo {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        String[] index = {"1","1","3"};
        for (int i = 0; i < index.length; i++) {
            list.add(index[i]);
            System.out.println(index[i]);
        }
        // map 用法 stmap
        list.stream().map(m->"3").collect(Collectors.toList()).forEach(s -> System.out.println(s));

        System.out.println("list size:"+list.stream().count());
        System.out.println("list 合并:"+list.stream().reduce((a, b)-> a + b).toString());
        System.out.println("list 拦截:"+list.stream().filter(f->f.equals("1")).reduce((a, b)-> a + b).toString());
        System.out.println("list 过滤:"+list.stream()
                .map(e -> e=e+"0")
                .reduce((a, b)-> a + b).toString());
        ImmutableList<String> imOflist= ImmutableList.of("peida","jerry","harry");
        System.out.println("imOflist："+imOflist);

        BiMap<Integer,String> logfileMap = HashBiMap.create();
        logfileMap.put(1,"a.log");
        logfileMap.put(2,"b.log");
        logfileMap.put(3,"c.log");
        System.out.println("logfileMap 提供了key和value的双向关联的数据结构 都不能重复:"+logfileMap);
        BiMap<String,Integer> filelogMap = logfileMap.inverse();
        System.out.println("filelogMap 提供了key和value的双向关联的数据结构:"+filelogMap);

        System.out.println("构造像Map<K, List<V>>或者Map<K, Set<V>>这样比较复杂的集合类型的数据结构");
    }
}
